package com.qen.fx;

import com.qen.fx.custom.CustomContent;
import com.qen.fx.custom.CustomSide;
import com.qen.fx.factory.SideCallback;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.beans.value.ObservableValue;
import javafx.event.Event;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.SplitPane;
import lombok.Data;

import javax.swing.text.View;
import java.net.URL;
import java.util.ResourceBundle;

@Data
public class IndexController implements Initializable {

    private final StringProperty titleText;
    private final StringProperty contentText;
    private final BooleanProperty isLike;
    private final StringProperty action;

    @FXML
    private CustomContent customContent;
    @FXML
    private CustomSide customSide;
    @FXML
    private SplitPane splitPane;

    public IndexController() {
        titleText = new SimpleStringProperty();
        contentText = new SimpleStringProperty();
        isLike = new SimpleBooleanProperty(false);
        action = new SimpleStringProperty();
    }

    @FXML
    @Override
    public void initialize(URL url, ResourceBundle resourceBundle) {
        customContent.setCustomSide(customSide);
        customContent.setTitleText(titleText.get());
        customContent.setContentText(contentText.get());
        customContent.setIsLike(isLike.get());
        customContent.setAction(action.get());

        splitPane.setDividerPositions(ViewIndex.sidePreferWidth / ViewIndex.WindowWidth, ViewIndex.contentPreferWidth / ViewIndex.WindowWidth);
    }

    @FXML
    public void goIndex() {

    }

    @FXML
    public void onClientSide(Event e) {

    }

}
